const path = require("path");
const utils = {
  assetsPath: function(_path) {
    const assetsSubDirectory =
      process.env.NODE_ENV === "production"
        ? // 生产环境下的 static 路径
          "static"
        : // 开发环境下的 static 路径
          "static";

    return path.posix.join(assetsSubDirectory, _path);
  },
  resolve: function(dir) {
    return path.join(__dirname, "..", dir);
  }
};
module.exports = {
  productionSourceMap: false,
  publicPath: "./",
  outputDir: "dist",
  lintOnSave: false,
  devServer: {
    port: 4567,
    open: true,
    hot: true,
    inline: true, // 实时刷新
    overlay: {
      warnings: false,
      errors: true
    }
  },
  // devServer: {
  //   https: false, // https:{type:Boolean}
  //   open: true, //配置自动启动浏览器
  //   proxy: {
  //     "/OneChaos/chaos/api": {
  //       target: "http://121.199.33.1:8888",
  //       ws: true,
  //       changeOrigin: true
  //     },
  //     "/OneChaos": {
  //       target: "http://127.0.0.1.:9998/",
  //       ws: true,
  //       changeOrigin: true
  //     }
  //   }
  // },

  css: {
    sourceMap: false,
    loaderOptions: {
      sass: {
        prependData: `@import "@/assets/varibles.scss"; 
											@import "@/assets/common.scss";
											@import "@/assets/layout.scss";`
      }
    }
  },

  configureWebpack: {
    module: {
      rules: [
        {
          test: /\.(woff2?|eot|ttf|otf)(\?.*)$/,
          loader: "url-loader",
          options: {
            limit: 10000,
            name: utils.assetsPath("fonts/[name].[hash:7].[ext]")
          }
        }
      ]
    }
  },

  pluginOptions: {
    electronBuilder: {
      builderOptions: {
        appId: "com.example.app",
        copyright: "moxin © 2021", //版权信息
        productName: "vue3Tools",
        directories: {
          output: "build" // 打包产物的位置
        },
        // extraFiles: [],
        // publish: [
        //   {
        //     provider: "generic",
        //     url: url
        //   }
        // ],
        nsis: {
          oneClick: false, // 是否一键安装
          allowElevation: true, // 允许请求提升，如果为false，则用户必须使用提升的权限重新启动安装程序。
          allowToChangeInstallationDirectory: true, // 允许修改安装目录
          // installerIcon: "build/icon/icon.ico", // 安装图标
          // uninstallerIcon: "build/icon/icon.ico", //卸载图标
          // installerHeaderIcon: "build/icon/icon.ico", // 安装时头部图标
          createDesktopShortcut: true, // 创建桌面图标
          createStartMenuShortcut: true, // 创建开始菜单图标
          shortcutName: "vue" // 图标名称
          // include: 'build/script/installer.nsh', // 包含的自定义nsis脚本
        },
        asar: false
      },
      win: {
        target: "nsis"
        // icon: "build/icon/icon.ico"
      }
    }
  }
};
